{{define "changepwd.html"}}
<!DOCTYPE html>
<html>
	<head>
        {{template "header"}}
	</head>

	<body>
		<div class="weadmin-nav">
            <span class="layui-breadcrumb">
                <a href="/welcome">首页</a>
                <a><cite>修改登录密码</cite></a>
            </span>
		</div>
		<div class="weadmin-body ">
			<form class="layui-form" lay-filter="changepwd_form">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label for="L_username" class="layui-form-label">
							用户名
						</label>
						<div class="layui-input-inline layui-text">
							{{.loginAccount}}
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label for="L_oldpwd" class="layui-form-label">
							<span class="we-red">*</span>旧密码
						</label>
						<div class="layui-input-inline">
							<input type="password" id="L_oldpwd" name="oldpwd" lay-verify="oldpwd" autocomplete="off" class="layui-input" placeholder="请输入旧密码">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label for="L_newpwd" class="layui-form-label">
							<span class="we-red">*</span>新密码
						</label>
						<div class="layui-input-inline">
							<input type="password" id="L_newpwd" name="newpwd" lay-verify="newpwd" autocomplete="off" class="layui-input" placeholder="新密码6到16个字符">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label for="L_repass" class="layui-form-label">
							<span class="we-red">*</span>确认新密码
						</label>
						<div class="layui-input-inline">
							<input type="password" id="L_repass" name="renewpwd" lay-verify="renewpwd" autocomplete="off" class="layui-input" placeholder="确认新密码">
						</div>
					</div>
				</div>

				<div class="layui-form-item ">
					<button class="layui-btn fr" lay-filter="okconfirm" lay-submit="">确定</button>
				</div>
			</form>
		</div>
    </body>

    {{template "jsfile"}}
	<script type="text/javascript">
		layui.extend({
			admin: '/static/js/admin',
		});
		layui.use(['jquery', 'form','element', 'admin', 'carousel'], function() {
			var element = layui.element,
				$ = layui.jquery,
				carousel = layui.carousel,
				form = layui.form,
				admin = layui.admin;
			//建造实例
			carousel.render({
				elem: '.weadmin-shortcut'
				,width: '100%' //设置容器宽度
				,arrow: 'none' //始终显示箭头
				,trigger: 'hover'
				,autoplay:false
			});

			form.verify({
				oldpwd: function(value){
					if(value.length <= 0){
						return '旧密码不允许为空!';
					}
				},
				newpwd: function(value){
					if(value.length < 6 || value.length > 16){
						return '新密码不允许为空!';
					}
				},
				renewpwd: function(value){
					if(value != $("#L_newpwd").val()){
						return '两次新密码不相同!';
					}
				}
			})

			//监听提交
			form.on('submit(okconfirm)', function(data){
				$.post("/changePwd",data.field,function(result){
					if(result.status){
						layer.msg("修改登录密码成功!",{time:3*1000,icon:1},function(){
							//自动关闭layer
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
						})
					}else{
						layer.msg(result.message,{time:6*1000,icon:2})
					}
				},"json");
				return false;
			});
		});
	</script>

</html>
{{end}}